/*
 * DialogInfo.java
 *
 * Created on 7. únor 2008, 21:23
 */

package jgaf.grammar;

/**
 *
 * @author  hanis
 */
public class DescriptionDiaog extends javax.swing.JDialog {
    
    /**
     * Creates new form DialogInfo
     */

    private String basicDescription;
    private String shortenDescription;

    public DescriptionDiaog(java.awt.Frame parent, String basicDescription, String shortenDescription) {
        super(parent, true);
        initComponents();
        this.basicDescription = basicDescription;
        this.shortenDescription = shortenDescription;

        setLocationRelativeTo(parent);

        
        buttonBack.setText("Close");
        radioBasic.setText("Basic");
        radioShorten.setText("Shorten");
        setTitle("Grammar detail");

        changeDescritpion();
        setVisible(true);
    }


    private void changeDescritpion() {
        if(radioBasic.isSelected()) {
            textArea.setText(basicDescription);
        } else {
            textArea.setText(shortenDescription);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        group = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        textArea = new javax.swing.JTextArea();
        buttonBack = new javax.swing.JButton();
        radioBasic = new javax.swing.JRadioButton();
        radioShorten = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pdasimulator/localization"); // NOI18N
        setTitle(bundle.getString("info.title")); // NOI18N
        setResizable(false);

        textArea.setColumns(20);
        textArea.setEditable(false);
        textArea.setRows(5);
        jScrollPane1.setViewportView(textArea);

        buttonBack.setText(bundle.getString("freq.back")); // NOI18N
        buttonBack.setMargin(new java.awt.Insets(1, 4, 1, 4));
        buttonBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonBackActionPerformed(evt);
            }
        });

        group.add(radioBasic);
        radioBasic.setSelected(true);
        radioBasic.setText("basic");
        radioBasic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBasicActionPerformed(evt);
            }
        });

        group.add(radioShorten);
        radioShorten.setText("shorten");
        radioShorten.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioShortenActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(radioBasic)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(radioShorten))
                    .add(buttonBack))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(radioBasic)
                    .add(radioShorten))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(buttonBack)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBackActionPerformed
        dispose();
    }//GEN-LAST:event_buttonBackActionPerformed

    private void radioBasicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBasicActionPerformed
        changeDescritpion();
    }//GEN-LAST:event_radioBasicActionPerformed

    private void radioShortenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioShortenActionPerformed
        changeDescritpion();
    }//GEN-LAST:event_radioShortenActionPerformed
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonBack;
    private javax.swing.ButtonGroup group;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JRadioButton radioBasic;
    private javax.swing.JRadioButton radioShorten;
    private javax.swing.JTextArea textArea;
    // End of variables declaration//GEN-END:variables
    
}
